package tests;

import common.Untils;
import org.openqa.selenium.By;

import java.io.IOException;

public class MyExercisePage extends Untils {
    public static String url = "http://8.155.1.153:8081/exercise";

    public MyExercisePage() {
        super(url);
    }

    public void exercise() throws InterruptedException, IOException {
        //查看我的练习数据
        screenshot(Thread.currentThread().getStackTrace()[1].getMethodName());
        Thread.sleep(2000);
        //点击第二个文件夹
        driver.findElement(By.xpath("//*[@id=\"rc-tabs-0-tab-undefined\"]/span")).click();
        //搜索题库
        Thread.sleep(2000);
        //输入关键词
        driver.findElement(By.xpath("//*[@id=\"name\"]")).sendKeys("测试");
        //重置输入框内容
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div[2]/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button/span")).click();
        //重新输入
        driver.findElement(By.xpath("//*[@id=\"name\"]")).sendKeys("测试");
        //点击查询
        Thread.sleep(2000);
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div[2]/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button/span")).click();
        //找到第一个符合名称的题库并且点击开始练习
        Thread.sleep(2000);
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[1]/td[3]/div/div/a")).click();
        //选择顺序练习的练习方式
        Thread.sleep(2000);
        driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[2]/div[1]")).click();
//        //选择是否答对自动跳转下一题,当前只有一题,所以无所谓
//        driver.findElement(By.xpath("//*[@id=\"root\"]/div[2]/div/div/div[5]/div[2]/div[2]/button")).click();
        //选择正确选项并且点击结束练习
        driver.findElement(By.xpath("//*[@id=\"root\"]/div[2]/div/div/div[4]/div/section/div[2]/div[1]/div/div/div[1]/label/span[2]/div")).click();
        driver.findElement(By.xpath("//*[@id=\"root\"]/div[2]/div/div/div[5]/div[2]/div[1]/button/div")).click();
        //练习完成后查看我的联系数据
        Thread.sleep(2000);
        screenshot(Thread.currentThread().getStackTrace()[1].getMethodName());


    }

}
